{include file="header.html"}
<style>
body{overflow: hidden;}
</style>
<script>
	$(function() {
		// 	$("[id^='num_']").each(function(){
		// 		var i=$(this).attr('item');
		// 		var max=$(this).attr('max');
		// 		if(!$("#cnum_"+i).get(0).checked){
		// 			continue;
		// 		}

		// 	});

		$("[id^='cnum_']").each(function() {
			var i = $(this).attr('item');
			if (this.checked) {
				var v = $("#num_" + i).val();
				var max = $("#num_" + i).attr('max');
				if (v > max) {
					$("#num_" + i).addClass("error");
				}
			}
		});

		$("#btnsubmit").click(function() {
			if (confirm('确定引入货物吗')) {

				var can = true;
				var item = 0;
				$("[id^='cnum_']").each(function() {
					if (!this.checked) {
						return true;
					}

					var i = $(this).attr('item');
					item++;
					var v = $("#num_" + i).val();
					var max = $("#num_" + i).attr('max');
					if (v == "" || isNaN(v) || parseInt(v) >parseInt(max)||parseInt(v)<=0) {
						$("#num_" + i).addClass("error");
						can = false;
					}
				});

				if (item <= 0) {
					alert("请选择集装箱");
					return false;
				}

				if (can) {
					$("#acategory_form").submit();
				}
			}
		});

		$("[id^='num_']").focus(function() {
			$(this).removeClass("error");
		});
	});
</script>
<div id="rightTop">
	<p>选择货物</p>
</div>

<div class="mrightTop">
	<div class="fontr">{include file=page.top.html}</div>
</div>
<div class="tdare">
	<form method="post" enctype="multipart/form-data" id="acategory_form"
		action="index.php?app=waybill&amp;act=choosegoodsdone">
		<input type="hidden" name="wm_code" value="{$wm_code}" id="wm_code">
		<input type="hidden" name="wm_tid" value="{$wmid}" id="wm_tid">
		<table width="100%" cellspacing="0" class="dataTable">

			<!--{if $goods}-->
			<tr class="tatr1">
				<td width="20" class="firstCell"><input type="checkbox"
					class="checkall" />
				</td>
				<td>货主</td>
				<td>船名</td>
				<td>航次</td>
				<td>提单号</td>
				<td>箱号</td>
				<td>箱型</td>
				<td>剩余箱量</td>
				<td>引入数量</td>

			</tr>
			<!--{/if}-->
			<!--{foreach from=$goods item=g}-->
			<tr class="tatr2">
				<td class="firstCell"><input type="checkbox"
					name="cnum[{$g.gs_tid}]" id="cnum_{$g.gs_tid}" class="checkitem"
					value="1" item="{$g.gs_tid}" />
				</td>
				<td>{$g.o_name}</td>
				<td>{$g.g_ship}</td>
				<td>{$g.g_voyage}</td>
				<td>{$g.g_awb_code}</td>
				<td>{$g.g_ctn_no}</td>
				<td>{$g.g_box}</td>
				<td>{$g.shengyu}</td>
				<td><input name="num[{$g.gs_tid}]" type="text" class=""
					value="{$g.shengyu}" max="{$g.shengyu}" id="num_{$g.gs_tid}"
					item="{$g.gs_tid}" />
				</td>
			</tr>
			<!--{foreachelse}-->
			<tr class="no_data">
				<td colspan="10">{$lang.no_data}</td>
			</tr>
			<!--{/foreach}-->
		</table>

		<!--{if $goods}-->
		<div id="dataFuncs">
			<div id="batchAction" class="left paddingT15">&nbsp;&nbsp;</div>
			<div class="pageLinks">{include file=page.bottom.html}</div>
			<!--{if $goods}-->
			<div id="dataFuncs">
				<div id="batchAction" class="left paddingT15">
					&nbsp;&nbsp; <input class="formbtn" type="button"
						value="引入" name="id" id="btnsubmit" />
				</div>
			</div>
			<!--{/if}-->
			<div class="clear"></div>
		</div>
		<!--{/if}-->
	</form>
</div>
{include file="footer.html"}
